package cn.wolfcode.shop.api.domain;

import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.*;

@Getter
@Setter
public class OrderInfo extends BaseDomain {

    public static final BigDecimal FREIGHT =  new BigDecimal("10.00");

    public static final int ORDER_NORMAL = 0;//未确认
    public static final int ORDER_CONFIRM = 1;//已确认
    public static final int ORDER_FINISH = 2;//已完成
    public static final int ORDER_CANCEL = 3;//已取消
    public static final int ORDER_INVALID = 4;//订单无效

    public static final int SHOP_NORMAL = 0;//未发货
    public static final int SHOP_CONFIRM = 1;//已发货
    public static final int SHOP_FINISH = 2;//已收货

    public static final int PAY_NORMAL = 0;//未支付
    public static final int PAY_CONFIRM = 1;//已支付

    private String orderSn;//订单编号

    private Long userId;//下单用户id

    private Byte orderStatus;//订单状态

    private Byte shippingStatus;//订单物流状态

    private Byte payStatus;//订单支付状态

    private String consignee;//收货人名字

    private String country;//收货国家

    private String province;//收货省份

    private String city;//收货城市

    private String district;//收货地区

    private String address;//收货具体地址

    private String zipcode;//收货邮政编码

    private String mobile;//收货人联系电话

    private BigDecimal orderAmount;//订单总价

    private Date orderTime;//订单时间

    private BigDecimal goodsAmount;//商品金额

    private Date payTime;//付款时间

    private Date sendTime;//发货时间

    private Date returnTime;//退货时间

    private String deliverSn;//发货单号

    private List<OrderProduct> orderProducts = new ArrayList<>();


    public String getOrderStatusDisplay(){
        switch (orderStatus){
            case ORDER_NORMAL : return "未确认";
            case ORDER_CONFIRM : return "已确认";
            case ORDER_FINISH : return "已完成";
            case ORDER_CANCEL : return "已取消";
            case ORDER_INVALID : return "订单无效";
            default: return "";
        }
    }
    public String getShippingStatusDisplay(){
        switch (shippingStatus){
            case SHOP_NORMAL : return "未发货";
            case SHOP_CONFIRM : return "已发货";
            case SHOP_FINISH : return "已收货";
            default: return "";
        }
    }
    public String getPayStatusDisplay(){
        switch (payStatus){
            case PAY_NORMAL : return "未支付";
            case PAY_CONFIRM : return "已支付";
            default: return "";
        }
    }
    public String getJsonString(){
        Map<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("orderSn", orderSn);
        map.put("mobile", mobile);
        map.put("consignee", consignee);
        map.put("orderStatus", orderStatus);
        map.put("address", address);
        map.put("zipcode", zipcode);
        map.put("country", country);
        map.put("province", province);
        map.put("city", city);
        map.put("district", district);
        map.put("address", address);
        map.put("orderAmount", orderAmount);
        map.put("goodsAmount", goodsAmount);
        map.put("payTime", payTime);
        map.put("sendTime", sendTime);
        map.put("returnTime", returnTime);
        map.put("orderTime", orderTime);
        map.put("deliverSn", deliverSn);
        return JSON.toJSONString(map);
    }

}